<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div class="FormDialog">
    <el-row>
      <el-col :span="24" class="margin_col">
        <dev>
          <div class="zhibo" style="width: 100%; height: 85vh;">
            <iframe :src="iframeUrl" frameborder="0" allowfullscreen="true" style="width: 100%; height: 100%;" allow="microphone; camera; display-capture"></iframe>
          </div>
      </dev>
      </el-col>
    </el-row>
  </div>
</template>

<script>

import axios from "axios";
import {postMethod} from "@/api/system/livelesson/quote";
// import {
//   saveFileInfo,
//   updateFileInfo,
//   queryFilesInfo
// } from '@/api/tpridmp/common/file.js'
export default {
  name: 'Worktaskform',
  components: {
  },
  props: {
    types: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      // userinfo: JSON.parse(sessionStorage.getItem("userinfo")),
      tablehide: false, // 课程附件是否隐藏
      tableData: [], // 课程附件
      editStatus: false, // 控制课程附件
      uploadUrl: "/omim_wisdom_safe_zdfd/process/Common_File?action=upload",
      moduletype: '课程库', // 模块类型
      moduleintype: "课程附件", // 子模块类型，默认为空
      dialogVisible: false, // table格式的上传组件是否显示 默认为false
      // 更新通知参数
      updatemessage: {
        businessid: '',
        msgtype: '',
        staffcode: '',
        msgresource: ''
      },
      pindaonum: '',
      iframeUrl: '',
      // iframeUrl: 'https://live.polyv.net/web-start/login?channelId=',
      leveloptions: [],
      specialoptions: [],
      sortoptions: [],
      depictoptions: [],
      singlehanderoptions: [{
        value: 1,
        label: '是'
      }, {
        value: 2,
        label: '否'
      }],
      value1: '',
      operationStatus: false,
      startDate: '',
      endDate: '',
      listLoading: false,
      datasDT: [],
      tableVisible: false, // 控制批量审核弹框
      formAudit: {
        ids: [],
        taskid: '',
        review: ''
      },
      canceltask: {
        ids: [],
        taskid: '',
        state: 6
      },
      isEdit: false, // 默认详情不可编辑
      showfinishedinfo: false, // 控制完成情况的显示与否，默认不显示
      showdelayreason: false, // 控制延期原因的显示与否，默认不显示
      tableHeight: 200,
      auditform: {
        taskid: '',
        finishedinfo: '',
        state: 3,
        // manager: JSON.parse(sessionStorage.getItem("userinfo")).code,
        finishdate: '',
        realyenddate: ''
      },
      delayprocessform: {
        taskid: '',
        delayreason: '',
        state: 5,
        // manager: JSON.parse(sessionStorage.getItem("userinfo")).code
      },
      dispatchflag: true, // 派发课程按钮可用
      cancelflag: true, // 取消课程变量初始化
      saveflag: true, // 保存按钮可用
      formData: {}, // 保存按钮可用
      editflag: true, // 编辑按钮控制
      tjshyqblbtn: 0, // 提交审核和延期办理按钮控制
      saveflow: 0, // 保存流程, 0:保存主表，1:保存完成情况，2:保存延迟原因
      selects: [],
      msg: '', // 查看传递的记录id
      taskid: '',
      detailid: ''
    }
  },
  created() {
    this.formData = this.$route.query.formData
    // this.iframeUrl = 'https://live.polyv.net/web-start/login?channelId='+this.formData.channelid;
    // 为 0 开启直播
    this.iframeUrl = "https://console.polyv.net/teacher/auth-login?" +
      "channelId=" + this.formData.channelid +
      "&token=" + this.formData.token +
      "&redirect=https://console.polyv.net/web-start/?channelId=" + this.formData.channelid
    // 为 0 开启直播
    // this.iframeUrl = "https://console.polyv.net/teacher/auth-login?" +
    //     "channelId=" + this.formDataFlow.channelid +
    //     "&token=" + this.formDataFlow.token +
    //     "&redirect=https://console.polyv.net/web-start/?channelId=" + this.formDataFlow.channelid
  },
  mounted() {
    // const iframe = this.$refs.myFrame;
    // iframe.onload = function() {
    //   const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
    //   const iframeHeight = iframeDocument.documentElement.scrollHeight;
    //   iframe.style.height = iframeHeight + 'px';
    // };
  },
  methods: {
    parentClick(id) {
      // this.$refs.mychild.queryDetail(id); // 调用子组件的方法queryDetail获取详细信息
    },
    /**
     * 编辑
     */
    edit() {
      this.saveflag = true;
      this.saveflow = 0;
      this.isEdit = true;
      this.editStatus = true;
    },
    // 课程附件--start
    success(fileList) {
      // 获取fileList
      this.tableData = this.tableData.concat(fileList);
    },
    failure(response) {
    },
    handleReturn() {
      // http://api.polyv.net/live/v2/channels/{channelId}/recordFiles
      axios({
        method: 'get',
        url: 'http://api.polyv.net/live/v2/channels/{channelId}/recordFiles?appId',
        headers: {
          'Content-Type': 'application/json' // 设置Content-Type为application/json
        }
      }).then(res => {
        console.log(res)
      }).catch(err => {
        console.error(err);
      });
      // 返回列表
      this.$emit('switchTable');
    },
    /**
     * 保存方法
     */
    saveValidate() {
      this.$refs['infoForm'].validate((valid) => {
        if (valid) {
          if (this.saveflow === 0) {
            this.savemain();
          }
        }
      });
    },
    savemain() {
      debugger
      this.formData.werks = this.userinfo.werks;// 工厂
      this.formData.bukrs = this.userinfo.bukrs;// 公司
      this.formData.create_by = this.userinfo.id;// 创建人
      this.formData.create_time = this.formData.adddate;// 创建时间
      this.formData.teachcast_time = dateFtt('yyyy-MM-dd hh:mm:ss', new Date(this.formData.teachcast_time));
      console.log(this.formData)
      postMethod('/omim_wisdom_safe_zdfd/process/setteachcast?method=save', this.formData).then(response => {
        const success = response.success;
        console.log(response)
        if (success === true) {
          this.$message.success('保存成功!');
          // 保存课程附件
          this.$emit('switchTable');
        } else {
          this.$message.error('数据保存失败!')
        }
      })
    }
  }
}
</script>
<style>
/*.zhibo{*/
/*  width: 100%;*/
/*  height: 80%;*/
/*}*/
/*iframe {*/
/*  margin: 0 auto;*/
/*  display: block;*/
/*  width: 100%;*/
/*  height: 80%;*/
/*}*/
</style>
